/*
 * Copyright 2022 The Open Islands Authors. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.openislands.oi.dao.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.Unique;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import org.apache.ibatis.type.EnumTypeHandler;
import org.openislands.oi.config.typehandler.JsonTypeHandler;
import org.openislands.oi.constant.AlgorithmType;
import org.openislands.oi.constant.OperatorPackagedType;
import org.openislands.oi.constant.OperatorType;

import java.io.Serializable;
import java.util.Map;

@TableName(value = "t_operator", autoResultMap = true)
public class OperatorDO extends BaseDO implements Serializable {
    @Unique(columns = {"f_type", "f_algorithm", "f_vendor_id", "f_version", "f_packaged_type"}, value = "sp_a_v_v_pt")
    @Column(type = MySqlTypeConstant.VARCHAR, length = 63, isNull = false)
    @TableField(value = "f_type", typeHandler = EnumTypeHandler.class)
    private OperatorType type;
    @Column(type = MySqlTypeConstant.VARCHAR, length = 63, isNull = false)
    @TableField(value = "f_algorithm", typeHandler = EnumTypeHandler.class)
    private AlgorithmType algorithm;
    @TableField("f_vendor_id")
    @Column(isNull = false, length = 10)
    private String vendorId;
    @TableField("f_version")
    @Column(isNull = false)
    private String version;
    @Column(type = MySqlTypeConstant.VARCHAR, length = 10, isNull = false)
    @TableField(value = "f_packaged_type", typeHandler = EnumTypeHandler.class)
    private OperatorPackagedType packagedType;

    @Column(type = MySqlTypeConstant.VARCHAR, length = 500, isNull = false)
    @TableField("f_driver")
    private String driver;
    @Column(type = MySqlTypeConstant.VARCHAR, length = 500, isNull = false)
    @TableField("f_entrypoint")
    private String entrypoint;
    @Column(type = MySqlTypeConstant.VARCHAR, length = 500, isNull = false)
    @TableField("f_source_uri")
    private String sourceUri;

    @Column(type = MySqlTypeConstant.TEXT)
    @TableField(value = "f_env", typeHandler = JsonTypeHandler.StringMap.class)
    private Map<String, String> env;
    @TableField("f_note")
    private String note;

    public OperatorType getType() {
        return type;
    }

    public void setType(OperatorType type) {
        this.type = type;
    }

    public AlgorithmType getAlgorithm() {
        return algorithm;
    }

    public void setAlgorithm(AlgorithmType algorithm) {
        this.algorithm = algorithm;
    }

    public String getVendorId() {
        return vendorId;
    }

    public void setVendorId(String vendorId) {
        this.vendorId = vendorId;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public OperatorPackagedType getPackagedType() {
        return packagedType;
    }

    public void setPackagedType(OperatorPackagedType packagedType) {
        this.packagedType = packagedType;
    }

    public String getEntrypoint() {
        return entrypoint;
    }

    public void setEntrypoint(String entrypoint) {
        this.entrypoint = entrypoint;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    public String getSourceUri() {
        return sourceUri;
    }

    public void setSourceUri(String sourceUri) {
        this.sourceUri = sourceUri;
    }

    public Map<String, String> getEnv() {
        return env;
    }

    public void setEnv(Map<String, String> env) {
        this.env = env;
    }

    public String getDriver() {
        return driver;
    }

    public void setDriver(String driver) {
        this.driver = driver;
    }
}